<template>
	<view>
		<view class="detail-box">
			<view class="cu-form-group">
				<view class="title">商品名称：</view>
				<input class="inpt" name="input" :value="NowSelectGoods.GoodsName"></input>
				<!-- <button class="cu-btn round stop text-white" @tap="gogoodlist">查询</button> -->
			</view>
			<view class="cu-form-group">
				<view class="title">编号：</view>
				<input class="inpt" name="input" :value="NowSelectGoods.GoodsCode"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">单位：</view>
				<view class="inpt1"><input type="text" placeholder="点击获取" :value="NowSelectGoods.UnitName" disabled="true" style="text-align: left;"
					 @input="filterUniName" />
					<button class="cu-btn  stop text-white" @tap="showModal" data-target='UnitNameModal'>查询</button>
					<view class="cu-modal" :class="modalName=='UnitNameModal'?'show':''">
						<view class="cu-dialog">
							<view class="cu-bar bg-white justify-end">
								<view class="content">请选择单位</view>
								<view class="action" @tap="hideModal">
									<text class="cuIcon-close text-red"></text>
								</view>
							</view>
							<view class="padding-xl">
								<view class="searchStore">
									<input placeholder="请输入名称" v-model="SearchUnitName" />
									<button @tap="searchUnitName">搜索</button>
								</view>
								<view class="StoreListWrap">
									<view v-for="(item,index) in TempUnitNameList" :key="index" @tap="selectUnitName(index)">{{item.UnitName}}</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="cu-form-group">
				<view class="title">单价：</view>
				<view class="inpt1"><input type="text" placeholder="点击获取" v-model="NowSelectGoods.Price" style="text-align: left;" />
					<button class="cu-btn  stop text-white" @tap="showModal" data-target='PriceModal'>查询</button>
					<view class="cu-modal" :class="modalName=='PriceModal'?'show':''">
						<view class="cu-dialog">
							<view class="cu-bar bg-white justify-end">
								<view class="content">请选择单价</view>
								<view class="action" @tap="hideModal">
									<text class="cuIcon-close text-red"></text>
								</view>
							</view>
							<view class="padding-xl">
								<view class="searchStore">
									<input placeholder="请输入名称" v-model="SearchPrice" />
									<button @tap="searchPrice">搜索</button>
								</view>
								<view class="StoreListWrap">
									<view v-for="(item,index) in PriceList" :key="index" @tap="selectPriceName(index)">{{item.ShowValue}}</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="cu-form-group">
				<view class="title">数量：</view>
				<input class="inpt" name="input" placeholder="点击修改" v-model="NowSelectGoods.Qty"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">折扣：</view>
				<input class="inpt" name="input" placeholder="点击修改" v-model="NowSelectGoods.Discount"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">税率：</view>
				<input class="inpt" name="input" placeholder="点击修改" v-model="NowSelectGoods.Tax"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">库存：</view>
				<input class="inpt" name="input" disabled="true" :value="NowSelectGoods.stockqty"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">调入仓库:</view>
				<view class="inpt1"><input type="text" placeholder="点击获取" :value="SelectInStoreObj.StoreName" disabled="true" style="text-align: left;"
					 data-target="StoreInModal" @tap="showModal" />
					<view class="cu-modal" :class="modalName=='StoreInModal'?'show':''">
						<view class="cu-dialog">
							<view class="cu-bar bg-white justify-end">
								<view class="content">请选择调入仓库</view>
								<view class="action" @tap="hideModal">
									<text class="cuIcon-close text-red"></text>
								</view>
							</view>
							<view class="padding-xl">
								<view class="searchStore">
									<input placeholder="请输入仓库名称" v-model="SearchInStoreName" />
									<button @tap="searchInStore">搜索</button>
								</view>
								<view class="StoreListWrap">
									<view v-for="(item,index) in StoreInList" :key="item.StoreID" @tap="selectInStore(index)">{{item.StoreName}}</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="cu-form-group">
				<view class="title">调出仓库:</view>
				<view class="inpt1"><input type="text" placeholder="点击获取" :value="SelectOutStoreObj.StoreName" disabled="true"
					 style="text-align: left;" data-target="StoreOutModal" @tap="showModal" />
					<view class="cu-modal" :class="modalName=='StoreOutModal'?'show':''">
						<view class="cu-dialog">
							<view class="cu-bar bg-white justify-end">
								<view class="content">请选择调出仓库</view>
								<view class="action" @tap="hideModal">
									<text class="cuIcon-close text-red"></text>
								</view>
							</view>
							<view class="padding-xl">
								<view class="searchStore">
									<input placeholder="请输入仓库名称" v-model="SearchOutStoreName" />
									<button @tap="searchOutStore">搜索</button>
								</view>
								<view class="StoreListWrap">
									<view v-for="(item,index) in StoreOutList" :key="item.StoreID" @tap="selectOutStore(index)">{{item.StoreName}}</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="cu-form-group">
				<view class="title">批号：</view>
				<input class="inpt" name="input" v-model="NowSelectGoods.BatchNo" v-if="NowSelectGoods.IsBatch && isBatchManger"></input>
				<input class="inpt" name="input" placeholder="不是批号商品" v-else></input>
				<button class="cu-btn  stop text-white" @tap="showModal" data-target='BrachModal' v-if="NowSelectGoods.IsBatch && isBatchManger">查询</button>
				<view class="cu-modal" :class="modalName=='BrachModal'?'show':''">
					<view class="cu-dialog">
						<view class="cu-bar bg-white justify-end">
							<view class="content">请选择批号</view>
							<view class="action" @tap="hideModal">
								<text class="cuIcon-close text-red"></text>
							</view>
						</view>
						<view class="padding-xl">
							<view class="StoreListWrap">
								<view v-for="(item,index) in storeList" :key="index" @tap="selectBrach(index)" class="StoreListItem">
									<!-- <view></view> -->
									<view class="Time"><text>批号:{{item.FBatchNo}}</text><text>数量：{{item.FQty}}</text></view>
									<view class="Time"><text>生产日期:{{item.FDate}}</text><text>有效日期:{{item.FValidDate}}</text></view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- <view class="cu-form-group">
				<view class="title">生产日期：</view>
				<block v-if="NowSelectGoods.IsBatch && isBatchManger">
					<picker mode="date" :value="ProductionDate.fulldate" @change="DateChangeStart">
						<view class="picker">
							{{ProductionDate.fulldate}}
						</view>
					</picker>
				</block>
				<block v-else>
					<input class="inpt" name="input" placeholder="不可选择"></input>
				</block> -->
				<!-- <input disabled="true" :value="SelectBrachObj.FDate" :placeholder="datePlaceHolder" v-if='orderType==10'></input> -->
			<!-- </view>
			<view class="cu-form-group">
				<view class="title">有效日期：</view>
				<!-- <input disabled="true" :value="SelectBrachObj.FValidDate" :placeholder="datePlaceHolder" v-if='orderType==10'></input> -->
				<!-- <block v-if="NowSelectGoods.IsBatch && isBatchManger">
					<picker mode="date" :value="validityDate.fulldate" @change="DateChangeEnd">
						<view class="picker">
							{{validityDate.fulldate}}
						</view>
					</picker>
				</block>
				<block v-else>
					<input class="inpt" name="input" placeholder="不可选择"></input>
				</block>
			</view> --> 
			<view class="cu-form-group">
				<view class="title">生产日期：</view>
				<block  v-if="NowSelectGoods.IsBatch && isBatchManger">
					<!-- <picker mode="date" :value="ProductionDate.fulldate" @change="DateChangeStart"  >
						<view class="picker">
							{{ProductionDate.fulldate}}
						</view>
					</picker> -->
					<input class="inpt" name="input" :value="SelectBrachObj.FDate"></input>
				</block>
				<block v-else>
					<input class="inpt" name="input" placeholder="不可选择"></input>
				</block>
				<!-- <input disabled="true" :value="SelectBrachObj.FDate" :placeholder="datePlaceHolder" v-if='orderType==10'></input> -->
			</view>
			<view class="cu-form-group" >
				<view class="title">有效日期：</view>
				<!-- <input disabled="true" :value="SelectBrachObj.FValidDate" :placeholder="datePlaceHolder" v-if='orderType==10'></input> -->
				<block  v-if="NowSelectGoods.IsBatch && isBatchManger">
					<input class="inpt" name="input" :value="SelectBrachObj.FValidDate"></input>
				<!-- <picker mode="date" :value="validityDate.fulldate" @change="DateChangeEnd" >
					<view class="picker">
						{{validityDate.fulldate}}
					</view>
				</picker> -->
				</block>
				<block v-else>
					<input class="inpt" name="input" placeholder="不可选择"></input>
				</block>
			</view>
			<view class="cu-form-group">
				<view class="title">备注：</view>
				<input class="inpt" name="input" placeholder="点击修改" v-model="NowSelectGoods.Remark"></input>
			</view>
		</view>
		<view class="cu-form-group">
			<!-- <button class="cu-btn  stop text-white" @tap="AddBillOrder">提交修改</button> -->
			<input class="inpt" name="input" disabled="true"></input>
			<button class="cu-btn  stop text-white" @tap="addSelectGoods">提交修改</button>
		</view>
		<uni-calendar ref="calendar1" :insert="false" @confirm="confirm1" />
		<uni-calendar ref="calendar2" :insert="false" @confirm="confirm2" />
	</view>
</template>
<script>
	import * as Api from '@/syApis/syAddOrder/syaddApis.js';
	import uniCalendar from '@/components/uni-calendar/uni-calendar.vue';
	export default {
		data() {
			return {
				//选择的商品
				NowSelectGoods: {},
				//添加的备注
				GoodsRemark: "",
				//商品库存
				GoodsStorm: 0,
				//商品税率
				Tax: 0,
				//商品
				GoodsQty: 0,
				//商品折扣
				GoodsDiscount: "",
				//仓库ID
				StoreID: "",
				//当前商品在原商品数组对应的位置
				index2: -1,
				index3: -1,
				picker2: [],
				// SelectStockNum:"",
				StoreList: [],
				startTime: "",
				endTime: "",
				//当前选择的调入仓库条目
				SelectInStoreObj: {
					StoreName: "",
					StoreID: ""
				},
				//当前选择的调出仓库条目
				SelectOutStoreObj: {
					StoreName: "",
					StoreID: ""
				},
				//调入仓库名称搜索
				SearchInStoreName: "",
				//调出仓库名称搜索
				SearchOutStoreName: "",
				//调出仓库的列表
				StoreOutList: [],
				//调入仓库的列表
				StoreInList: [],
				modalName: null,
				//多单位列表
				UnitNameList: [],
				//多单位搜索
				SearchUnitName: "",
				//价格跟踪
				PriceList: [],
				//价格跟踪搜索
				SearchPrice: "",
				//当前选择的批号
				SelectBrachObj: {
					FBatchNo: "",
					FDate: "",
					FValidDate: ""
				},
				//批号过滤
				SearchBrachName: "",
				storeList: [],
				Inventorybatch: "",
				//生产日期
				ProductionDate: {
					fulldate: ""
				},
				//有效日期
				validityDate: {
					fulldate: ""
				},
				TempUnitNameList: [],
				ClientID: "",
				isBatchManger: true
			}
		},
		created() {
			this.GetStoreMessage();

		},
		onLoad(options) {
			console.log(options);
			let goodData = uni.getStorageSync("ChangeGoodData", "");
			var that = this;
			let SystemSettingInfo = uni.getStorageSync("SystemSettingInfo", ""); //存储系统设置
			SystemSettingInfo = JSON.parse(SystemSettingInfo);
			SystemSettingInfo.forEach((item, index) => {
				// if (item.SystemName == '是否允许负库存出库') {
				// 	if (item.Value == "1") {
				// 		that.isNumQtStorm = true;
				// 	}
				// 	// console.log(item.Value);
				// }
				// if (item.SystemName == '售价低于进价提示') {
				// 	if (item.Value == "1") {
				// 		that.isTipPrice = true;
				// 	}
				// 	// console.log(item.Value);
				// }
				if (item.SystemName == '开启批号管理') {
					if (item.Value != "1") {
						that.isBatchManger = false;
					}
					// console.log(item.Value);
				}
			});
			if (goodData != "") {
				this.NowSelectGoods = JSON.parse(goodData);
			}
			this.BillName = options.BillName;
			this.StoreID = options.StoreID;
			this.index = options.selectIndex;
			this.Inventorybatch = options.Inventorybatch;
			this.ClientID = options.ClientID || "";
			if (this.NowSelectGoods.IsBatch) {
				this.XHGetBatchNoFollow();
			}
			this.Get_GoodsUnitMessage();
			let date = new Date();
			// let AddDate = new Date();
			// AddDate.setDate(AddDate.getDate()+this.NowSelectGoods.Days);
			
			if(this.NowSelectGoods.ProductionDate == ""){
				if(this.NowSelectGoods.IsBatch && this.isBatchManger){
					this.ProductionDate.fulldate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
					this.NowSelectGoods.ProductionDate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
				}
				
				// this.SelectBrachObj.FDate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
			}else{
				this.ProductionDate.fulldate = this.NowSelectGoods.ProductionDate;
				// this.NowSelectGoods.ProductionDate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
			}
			
			if(this.NowSelectGoods.validityDate==""){
				if(this.NowSelectGoods.IsBatch && this.isBatchManger){
					this.validityDate.fulldate = this.getVarDate(this.NowSelectGoods.Days);
					this.NowSelectGoods.validityDate = this.getVarDate(this.NowSelectGoods.Days);
				}
				
				
			}else{
				this.validityDate.fulldate = this.NowSelectGoods.validityDate;
				this.NowSelectGoods.validityDate = this.NowSelectGoods.validityDate;
			}
			
			
			console.log(this.validityDate.fulldate);
			

		},
		components: {
			uniCalendar
		},
		methods: {
			//选择批号
			selectBrach(index) {
				this.SelectBrachObj = this.storeList[index];
				this.NowSelectGoods.BatchNo = this.storeList[index].FBatchNo;
				this.NowSelectGoods.ProductionDate = this.storeList[index].FDate;
				this.NowSelectGoods.validityDate = this.storeList[index].FValidDate;
				this.ProductionDate.fulldate = this.storeList[index].FDate;
				this.validityDate.fulldate = this.storeList[index].FValidDate;
				this.NowSelectGoods.stockqty = Math.round(this.storeList[index].FQty*100)/100 ;
				console.log(this.NowSelectGoods);
				this.modalName = null;
			},
			//分割日期
			getFirstDay(value) {
				if (value != '' || typeof value != 'undefined') {
					return value.split(" ")[0];
				} else {
					return "";
				}
			},
			getVarDate(days) {
				console.log(days);
				let date = new Date();
				let time = date.getTime() + days * 24 * 60 * 60 * 1000;
				let AddDate = new Date(time);
				console.log(AddDate.getFullYear());
				// let date = new Date();
				var month = AddDate.getMonth() + 1;
				if (month < 10) {
					month = "0" + month
				}
				var day = AddDate.getDate();
				if (day < 10) {
					day = "0" + day;
				}
				return AddDate.getFullYear() + "-" + month + "-" + day;
			},
			//生产日期修改后赋值有效日期
			changeBirToHasEat(val,days){
				if(val == "" || typeof val == 'undefined'){
					return "";
				}
				val = val.replace(/-/g,'/');
				var date = new Date(val);
				let time =  date.getTime()+days*24*60*60*1000;
				let AddDate = new Date(time);
				var month = AddDate.getMonth() + 1;
				if (month < 10) {
					month = "0" + month
				}
				var day = AddDate.getDate();
				if (day < 10) {
					day = "0" + day;
				}
				return AddDate.getFullYear() + "-" + month + "-" + day;
			},
			
			//有效日期修改后赋值生产日期
			changeHasEatToBir(val,days){
				if(val == "" || typeof val == 'undefined'){
					return "";
				}
				val = val.replace(/-/g,'/');
				var date = new Date(val);
				let time =  date.getTime()-days*24*60*60*1000;
				let AddDate = new Date(time);
				var month = AddDate.getMonth() + 1;
				if (month < 10) {
					month = "0" + month
				}
				var day = AddDate.getDate();
				if (day < 10) {
					day = "0" + day;
				}
				return AddDate.getFullYear() + "-" + month + "-" + day;
			},
			//获取当前选择的商品的库存
			SelectStockNum() {
				let data = {
					StoreID: this.NowSelectGoods.StoreID,
					GoodsID: this.NowSelectGoods.GoodsID,
					BillName: this.BillName
				};
				var _this = this;
				Api.SelectStockNum(data, (res) => {
					if (res.data.ErrorMsg == "获取登录信息失败") {

					} else if (res.data.ErrorMsg != "") {
						Api.showTip(res.data.ErrorMsg);
					} else {
						_this.GoodsStorm = res.data.ResultMsg;
						_this.NowSelectGoods.stockqty = res.data.ResultMsg;
					}
				});
			},
			DateChangeStart(e) {
				this.ProductionDate.fulldate = e.detail.value;
				this.NowSelectGoods.ProductionDate = e.detail.value;
			},
			DateChangeEnd(e) {
				this.validityDate.fulldate = e.detail.value;
				this.NowSelectGoods.validityDate = e.detail.value;
			},
			//获取批号
			XHGetBatchNoFollow(Filter = '') {
				let data = {
					StoreID: this.StoreID,
					GoodsID: this.NowSelectGoods.GoodsID,
					BillName: this.BillName,
					Inventorybatch: this.Inventorybatch,
					Filter
				};
				var self = this;
				Api.XHGetBatchNoFollow(data, function(res) {
					if (res.state) {
						if (res.data.ErrorMsg == '获取登录信息失败') {

						} else if (res.data.ErrorMsg != '') {

						} else {
							self.storeList = res.data.ResultMsg;
							self.storeList.forEach((item, index) => {
								self.storeList[index].FDate = self.getFirstDay(self.storeList[index].FDate);
								self.storeList[index].FValidDate = self.getFirstDay(self.storeList[index].FValidDate);
							})
						}
					}
				})
			},
			//多单位搜索
			searchUnitName() {
				let Filter = "";
				if (this.SearchUnitName != '') {
					Filter = "UnitName like '%" + this.SearchUnitName + "%'";
					this.Get_GoodsUnitMessage(Filter);
				} else {
					this.Get_GoodsUnitMessage();
				}
			},
			filterUniName(e) {
				let value = e.detail.value;
				this.TempUnitNameList = [];
				var that = this;
				this.UnitNameList.forEach((item, index) => {
					if (item.UnitName.indexOf(value) > -1) {
						that.TempUnitNameList.push(item);
					}
				});
				if (that.TempUnitNameList.length == 0) {
					Api.showTip("查无数据");
				}
			},
			//多单位点击
			selectUnitName(index) {
				this.NowSelectGoods.UnitName = this.TempUnitNameList[index].UnitName;
				this.NowSelectGoods.urate = this.TempUnitNameList[index].urate;
				this.NowSelectGoods.UnitID = this.TempUnitNameList[index].UnitID;
				this.XH_Get_PriceFollowMessage(this.TempUnitNameList[index]);
				this.modalName = null;
			},
			//价格跟踪搜索
			searchPrice() {
				let Filter = "";
				if (this.SearchPrice != '') {
					Filter = "ShowValue like '%" + this.SearchPrice + "%'";
					this.XH_Get_PriceFollowMessage(this.NowSelectGoods, Filter);
				} else {
					this.XH_Get_PriceFollowMessage(this.NowSelectGoods);
				}
			},

			//多单位点击
			selectPriceName(index) {
				this.NowSelectGoods.Price = this.PriceList[index].Price;
				this.NowSelectGoods.PFPrice = this.PriceList[index].Price;
				this.modalName = null;
			},
			//价格跟踪
			XH_Get_PriceFollowMessage(priceItem, Filter = "") {
				let data = {
					GoodsID: priceItem.GoodsID,
					UnitID: priceItem.UnitID,
					BillName: this.BillName,
					URate: priceItem.urate,
					ClientID: this.ClientID,
					StoreID:this.StoreID
				}
				var that = this;
				Api.XH_Get_PriceFollowMessage(data, function(res) {
					if (res.state) {
						if (res.data.ResultMsg != "") {
							that.PriceList = res.data.ResultMsg;

							that.NowSelectGoods.Price = that.PriceList[0].Price;
							// that.NowSelectGoods.PFPrice = that.PriceList[0].Price;
							// 
						} else if (res.data.ErrorMsg == '获取登录信息失败') {
							Api.showTip(res.data.ErrorMsg);
						} else {
							Api.showTip(res.data.ErrorMsg);
						}
					} else {

					}
				});
			},
			//查询商品多单位
			Get_GoodsUnitMessage(Filter = '') {
				let data = {
					GoodsID: this.NowSelectGoods.GoodsID,
					Filter: Filter
				}
				var that = this;
				Api.Get_GoodsUnitMessage(data, function(res) {
					if (res.state) {
						if (res.data.ResultMsg != "") {
							if (Filter != "") {
								that.TempUnitNameList = res.data.ResultMsg;
							} else {
								that.TempUnitNameList = res.data.ResultMsg;
								that.UnitNameList = res.data.ResultMsg;
							}

							if (that.TempUnitNameList.length > 0) {
								that.TempUnitNameList.forEach((item, index) => {
									if (item.UnitID == that.NowSelectGoods.UnitID) {
										that.XH_Get_PriceFollowMessage(that.TempUnitNameList[index]);
									}
								})

							}
						} else if (res.data.ErrorMsg == '获取登录信息失败') {
							Api.showTip(res.data.ErrorMsg);
						} else {
							Api.showTip(res.data.ErrorMsg);
						}
					} else {

					}
				});
			},
			//显示弹框
			showModal(e) {
				this.modalName = e.currentTarget.dataset.target
			},
			hideModal() {
				this.modalName = null;
			},
			//调入仓库搜索
			searchInStore() {
				if (this.SearchInStoreName != "") {
					let Filter = "StoreName like '%" + this.SearchInStoreName + "%'";
					this.GetStoreMessage(Filter, 0);
				} else {
					this.GetStoreMessage();
				}
			},
			//调出仓库搜索
			searchOutStore() {
				if (this.SearchOutStoreName != "") {
					let Filter = "StoreName like '%" + this.SearchOutStoreName + "%'";
					this.GetStoreMessage(Filter, 1);
				} else {
					this.GetStoreMessage();
				}
			},
			//调入仓库选择
			selectInStore(index) {
				this.SelectInStoreObj = this.StoreInList[index];
				this.NowSelectGoods.StoreID2 = this.StoreInList[index].StoreID;
				this.modalName = null;
			},
			//调出仓库选择
			selectOutStore(index) {
				this.SelectOutStoreObj = this.StoreOutList[index];
				this.NowSelectGoods.StoreID = this.StoreOutList[index].StoreID;
				this.SelectStockNum();
				this.modalName = null;
			},
			open1() {
				this.$refs.calendar1.open();
			},
			confirm1(e) {
				// var fulldate = e.detail.fulldate
				// console.log(e.detail.fulldate);
				console.log(e)
				this.startTime = e.fulldate;
				this.NowSelectGoods.startTime = e.fulldate;
			},
			open2() {
				this.$refs.calendar2.open();
			},
			confirm2(e) {
				// var fulldate = e.detail.fulldate
				// console.log(e.detail.fulldate);
				console.log(e)
				this.endTime = e.fulldate;
				this.NowSelectGoods.EndTime = e.fulldate;
			},
			//获取仓库
			GetStoreMessage(Filter = "", isIntOut = 2) {
				let data = {
					Filter: Filter
				}
				var that = this;
				Api.GetStoreMessage(data, function(res) {
					if (res.state) {
						if (res.data.ErrorMsg == "获取登录信息失败") {
							Api.showTip("登录超时");
						} else if (res.data.ErrorMsg != "") {
							Api.showTip(res.data.ErrorMsg);
						} else {
							let responseData = res.data.ResultMsg;
							// that.StoreList = res.data.ResultMsg;
							res.data.ResultMsg.forEach(item => {
								if (that.NowSelectGoods.StoreID == item.StoreID) {
									that.SelectOutStoreObj = item;
								}
								if (that.NowSelectGoods.StoreID2 == item.StoreID) {
									that.SelectInStoreObj = item;
								}
							});
							if (isIntOut == 0) {
								that.StoreInList = res.data.ResultMsg;
							} else if (isIntOut == 1) {
								that.StoreOutList = res.data.ResultMsg;
							} else {
								that.StoreInList = res.data.ResultMsg;
								that.StoreOutList = res.data.ResultMsg;
							}
						}
					} else {

					}
				});
			},
			PickerChange2(e) {
				console.log(e)
				this.index2 = e.detail.value;
				this.NowSelectGoods.StoreID = this.StoreList[e.detail.value].StoreID;
			},
			PickerChange3(e) {
				console.log(e)
				this.index3 = e.detail.value;
				this.NowSelectGoods.StoreID2 = this.StoreList[e.detail.value].StoreID2;
			},
			//折扣改变事件
			changeZk(e) {
				console.log(e);
			},
			//获取当前选择的商品
			addSelectGoods() {
				// this.NowSelectGoods.GoodsStorm = this.GoodsStorm;
				console.log(this.NowSelectGoods);
				if (this.NowSelectGoods.Qty <= 0 || this.NowSelectGoods.Qty == "") {
					Api.showTip("商品数量不能少于一件");
					return;
				}
				if(this.NowSelectGoods.BatchNo==""&&this.NowSelectGoods.IsBatch&&this.isBatchManger){
					Api.showTip("批号不能为空");
					return;
				}
				let DiscountStr = this.NowSelectGoods.Discount+'';
				if(DiscountStr.indexOf(".")>-1){
					Api.showTip("折扣只能是整数");
					return;
				}
				let TaxStr = this.NowSelectGoods.Tax+'';
				// console.log(this.NowSelectGoods.Tax+''.indexOf("."));
				if(TaxStr.indexOf(".")>-1){
					Api.showTip("税率只能是整数");
					return;
				}
				let data = {};
				data.index = this.index;
				this.DiscountPrice();
				this.Amount();
				// console.log(this.NowSelectGoods);
				// return;
				data.NewGoodInfo = JSON.stringify(this.NowSelectGoods);
				this.$eventHub.$emit('fire', data);
				uni.navigateBack({
					delta: 1
				})
			},
			DiscountPrice() {
				this.NowSelectGoods.DiscountPrice = parseFloat(this.NowSelectGoods.Price) * (parseFloat(this.NowSelectGoods.Discount) /
					100) * (1 + parseFloat(
					this.NowSelectGoods.Tax) / 100);
			},
			//计算总价
			Amount() {
				this.NowSelectGoods.Amount = parseFloat(this.NowSelectGoods.Price) * parseFloat(this.NowSelectGoods.Qty) * (
					parseFloat(this.NowSelectGoods.Discount) / 100) * (1 + parseFloat(
					this.NowSelectGoods.Tax) / 100);
				// return  PFPrice;
			},
			//计算折扣后商品价格
			computPrice(item) {
				item.PFPrice = item.PFPrice * item.Qty * (item.Discount / 100) * (1 + item.Tax / 100);
				return item;
			}
		}
	}
</script>

<style>
	/* @import url("./goodlist.css"); */
	.stop {
		background: rgba(124, 170, 216, 1) !important;
	}

	.inpt1 {
		flex: 1;
		text-align: left;
		align-items: center;
		display: flex;
	}

	/* 弹框样式 */
	.padding-xl .searchStore {
		display: flex;
		width: 100%;
		margin: auto;
		height: 45px;
		padding-top: 5px;
		font-size: 14px;
	}

	.padding-xl .searchStore input {
		flex: 1;
		height: 35px;
		border: 1px solid #CCC;
		border-top-left-radius: 5px;
		border-bottom-left-radius: 5px;
		padding-left: 10px;
	}

	.padding-xl {
		padding: 10px;

	}

	.padding-xl .searchStore button {
		font-size: 14px;
		color: #FFF;
		padding-left: 8px;
		padding-right: 8px;
		height: 35px;
		line-height: 35px;
		border-radius: 0px;
		border-top-right-radius: 5px;
		border-bottom-right-radius: 5px;
		text-align: center;
		background: rgba(124, 170, 216, 1);
	}

	.padding-xl .StoreListWrap {
		height: 250px;
		overflow: auto;
	}

	.padding-xl .StoreListWrap view {
		height: 40px;
		line-height: 40px;
		text-align: left;
		border-bottom: 1px solid #CCC;
		padding-left: 8px;
	}

	.cu-form-group {
		padding: 1px 10px !important;
		height: 40px;
		line-height: 40px;
		min-height: 40px;
	}
	
	.padding-xl .StoreListWrap .StoreListItem {
		height: 60px;
		line-height: 30px;
		border-bottom: 1px solid #CCC;
	}
	
	.padding-xl .StoreListWrap .StoreListItem view {
		display: flex;
		border-bottom: none;
		height: 30px;
		line-height: 30px;
	}
	
	.padding-xl .StoreListWrap .StoreListItem view text {
		flex: 1;
	}
</style>
